﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TulingMember.Database.Migrations.Migrations
{
    public partial class updatetableproductfkpk : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<long>(
                name: "SaleOrderId",
                table: "cts_SaleOrderDetail",
                type: "bigint",
                nullable: true);

            migrationBuilder.AlterColumn<DateTime>(
                name: "ManufacturingDate",
                table: "cts_PurchaseOrderDetail",
                type: "datetime2",
                nullable: true,
                oldClrType: typeof(DateTime),
                oldType: "datetime2");

            migrationBuilder.AlterColumn<DateTime>(
                name: "ExpirationDate",
                table: "cts_PurchaseOrderDetail",
                type: "datetime2",
                nullable: true,
                oldClrType: typeof(DateTime),
                oldType: "datetime2");

            migrationBuilder.UpdateData(
                table: "Role",
                keyColumn: "Id",
                keyValue: 142307070910554L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(6279), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910555L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(7313), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910556L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(7323), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910557L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(7325), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "User",
                keyColumn: "Id",
                keyValue: 142307070910551L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 603, DateTimeKind.Unspecified).AddTicks(4734), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.CreateIndex(
                name: "IX_cts_SaleOrderDetail_ProductId",
                table: "cts_SaleOrderDetail",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_cts_SaleOrderDetail_SaleOrderId",
                table: "cts_SaleOrderDetail",
                column: "SaleOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_cts_PurchaseOrderDetail_ProductId",
                table: "cts_PurchaseOrderDetail",
                column: "ProductId");

            migrationBuilder.AddForeignKey(
                name: "FK_cts_PurchaseOrderDetail_cts_Product_ProductId",
                table: "cts_PurchaseOrderDetail",
                column: "ProductId",
                principalTable: "cts_Product",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_Product_ProductId",
                table: "cts_SaleOrderDetail",
                column: "ProductId",
                principalTable: "cts_Product",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_SaleOrder_SaleOrderId",
                table: "cts_SaleOrderDetail",
                column: "SaleOrderId",
                principalTable: "cts_SaleOrder",
                principalColumn: "Id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_cts_PurchaseOrderDetail_cts_Product_ProductId",
                table: "cts_PurchaseOrderDetail");

            migrationBuilder.DropForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_Product_ProductId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.DropForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_SaleOrder_SaleOrderId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.DropIndex(
                name: "IX_cts_SaleOrderDetail_ProductId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.DropIndex(
                name: "IX_cts_SaleOrderDetail_SaleOrderId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.DropIndex(
                name: "IX_cts_PurchaseOrderDetail_ProductId",
                table: "cts_PurchaseOrderDetail");

            migrationBuilder.DropColumn(
                name: "SaleOrderId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.AlterColumn<DateTime>(
                name: "ManufacturingDate",
                table: "cts_PurchaseOrderDetail",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                oldClrType: typeof(DateTime),
                oldType: "datetime2",
                oldNullable: true);

            migrationBuilder.AlterColumn<DateTime>(
                name: "ExpirationDate",
                table: "cts_PurchaseOrderDetail",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                oldClrType: typeof(DateTime),
                oldType: "datetime2",
                oldNullable: true);

            migrationBuilder.UpdateData(
                table: "Role",
                keyColumn: "Id",
                keyValue: 142307070910554L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 25, 22, 57, 21, 583, DateTimeKind.Unspecified).AddTicks(2448), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910555L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 25, 22, 57, 21, 583, DateTimeKind.Unspecified).AddTicks(3505), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910556L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 25, 22, 57, 21, 583, DateTimeKind.Unspecified).AddTicks(3515), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910557L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 25, 22, 57, 21, 583, DateTimeKind.Unspecified).AddTicks(3516), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "User",
                keyColumn: "Id",
                keyValue: 142307070910551L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 25, 22, 57, 21, 583, DateTimeKind.Unspecified).AddTicks(9678), new TimeSpan(0, 8, 0, 0, 0)));
        }
    }
}
